pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let mut num_string = String::new();
    let mut from_base = 0;
    let mut state = 0;
    for c in num_str.chars() {
        if c == '(' {
            state = 1;
        } else if c.is_numeric() {
            match state {
                0 => num_string.push(c),
                1 => {
                    from_base *= 10;
                    from_base += c.to_digit(10).unwrap();
                }
                _ => unreachable!(),
            }
        }
    }

    let mut num = 0;

    for c in num_string.chars() {
        let digit = c.to_digit(from_base).unwrap();
        num *= from_base;
        num += digit;
    }

    let mut result = String::new();

    while num > 0 {
        let digit = num % to_base;
        num /= to_base;
        result.insert(0, char::from_digit(digit, to_base).unwrap());
    }

    result
}
